Many commercially available Operating Systems use copy-on-write as a method to achieve optimization in operations. Copy-on-write is used in a fork operation, where the OS (Operating System) creates a replica of a process (i.e., a running instance of an application). The original process requesting the fork operation is the parent process and the newly created process is the child process. The child process expects to have a copy of the contents of parent's address space at the time of fork. Copy-on-write is an optimization that causes physical memory pages of the parent process to be shared with the child process for memory read operations. These shared pages are marked by the OS as copy-on-write. A page that is marked copy-on-write will remain as a shared page to the parent process and child process even if both processes perform read operation on the shared page.
However, when either the parent process or the child process writes to a shared page that is marked copy-on-write, a page fault exception occurs, where the process that is performing the write operation is given a copy of the page to be written. Writing to the copy prevents the process from writing on the shared page and therefore avoids corruption of memory data for the other process that shares the page. After a process writes to that copied page, that page will remain visible to that process but will not be visible to other processes until there is another instance of an event such as fork that will mark the new page copy-on-write once again. The use of copy-on-write permits a very efficient fork operation because copying all pages of the parent process onto the address space of the child process is avoided by use of the shared pages.
Copy-on-write is also used for data segments of a shared library, where multiple processes attached to the shared library get read-only access on the data segments. When a process writes to the data portion of the shared library, a copy-on-write exception is taken in order to give a private copy of the data for the process, and the process then performs the write access to the private copy.
When a process possessing pages that are marked copy-on-write attempts to write to one of those pages, an exception (page fault exception or copy-on-write exception) that occurs tells the OS to first stall the process so that the write access of the process is delayed. The OS allocates a new dedicated page for the process, and copies data from the shared page to the new dedicated page. The OS will subsequently detach the process from the shared page, update the virtual memory to physical memory translation with the new dedicated page allocated, and then release the process so that the process performs the write access to the new dedicated page.
When a portion of a memory that is marked copy-on-write is also registered with an RDMA (Remote Direct Memory Access) device, then that memory will also be exposed to remote applications on a different computer via the RDMA protocol. As known to those skilled in the art, the RDMA protocol provides a useful method for reducing system processor work in the transmission and reception of data across a network and in other network-related processing. Prior methods do not stall the write attempts from the remote applications to a shared page of local applications, before the OS can allocate a new dedicated page for the write attempts such as an RDMA-write or RDMA-send from a remote application. Therefore, there is a risk that a remote application will corrupt the data in the memory (marked copy-on-write) of local applications (in the local node) because of the write attempts that occur to a shared page. Furthermore, while it is acceptable for the local application that exposed the memory for RDMA to see the modifications by the remote applications, the other local applications sharing the page would not be aware of the access by remote applications via RDMA, and they would see this as corruption of their data.
Therefore, the current technology is limited in its capabilities and suffers from at least the above constraints and deficiencies.